 (function ($) {
    $.fn.panelToggle = function(options) {
        //隐藏其他叶窗
        this.toggle().siblings('.' + options).hide();

        //切换菜单图标
        $('.' + options).each(function(){
            if ($(this).is(':visible')) {
                $(this).prev().removeClass('accordioned').addClass('accordioned_v');
            } else {
                $(this).prev().removeClass('accordioned_v').addClass('accordioned');
            }
        }); 
    };
})(jQuery);

//伸缩按钮点击事件 flag判断伸缩
//$('body').on('click', '##list-btn', function () {  
$('#list-btn').click(function(){
	
    if ($('#list-box').hasClass('flag')) {

        $('#list-box').removeClass('flag').addClass('open');
        $('.fadeBtn').addClass('in').removeClass('out');
        $('#list-container').animate({right: '-0'}, 'slow');
    } else {
        
        $('#list-box').removeClass('open').addClass('flag');
        $('.fadeBtn').removeClass('in').addClass('out');
        $('#list-container').animate({right: '+0'}, 'slow');
    }
});

 /**
 * [窗口大小改变时]
 * @AuthorHTL zoro
 * @DateTime  2017-08-06T16:17:44+0800
 */
$(window).resize(function() {
    console.log('change');
    adjustWindow();
});

//图片打印
function printById(id) {
	var $previewIframe=parent.$('#main');
	debugger

//	html2canvas($previewIframe.contents().find('#'+id+' .ol-unselectable'),{
	$('.ol-unselectable').css('display','block');
    html2canvas($("#"+id+" .ol-unselectable")[0], {
        allowTaint : true,
        taintTest : false,
        onrendered : function(canvas) {
            //生成base64图片数据
            var dataUrl = canvas.toDataURL();
            var a = $("<a></a>").attr("href", dataUrl).attr("download", "img.png").appendTo("body");
            a[0].click();
            a.remove();
        }
    });
    
    
}

/**
 * [自适应窗口]
 * @AuthorHTL zoro
 * @DateTime  2017-08-06T16:12:21+0800
 */
function adjustWindow() {
    resizeBtnMiddle();
    
    $('#map').css('height',$(window).height()-5);
    $('#map canvas').css('height',$(window).height()-5);
}

/**
 * [动态改变伸缩按钮位置，让按钮处于叶窗中间]
 * @DateTime  2017-08-06T16:32:23+0800
 */
 function resizeBtnMiddle() {
    $('.fadeBtn').css('top',($('#list-container').height() - $('.fadeBtn').height())/2);
}